
const tokens = {
  admin: {
    token: 'admin-token'
  },
  editor: {
    token: 'editor-token'
  }
}

const users = {
  'admin-token': {
    roles: ['admin'],
    introduction: 'I am a super administrator',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'Super Admin',
    menus:[
      {
        path: '/',
        component:'/layout',
        redirect: '/dashboard',
        children: [
          {
            path: '/dashboard',
            component: 'dashboard/index',
            name: 'Dashboard',
            meta: { title: '首页', icon: 'el-icon-s-home', affix: true,id:1,parentId:0 }
          },
          {
            path: '/blank',
            component: 'layout/index',
            //redirect: '/userMgt/user',
            alwaysShow: true, // will always show the root menu
            name: 'UserMgtSys',
            meta: {
              id:11,
              title: '系统管理',
              icon: 'el-icon-user-solid',
              parentId:0,
              roles: ['admin']// you can set roles in root nav
            },
            children: [
              {
                path: '/userMgt/user',
                component: 'userMgt/userMgt',
                name: 'UserMgt',
                meta: {
                  id:111,
                  parentId:11,
                  title: '用户管理',
                  icon:'el-icon-user',
                  roles: ['admin'], // or you can only set roles in sub nav
                  btnPermission:[
                    {
                      label:'新建',
                      value:'add',
                      id:1111,
                      checked:false
                    }
                  ]
                }
              },{
                path: '/userMgt/role',
                component: 'userMgt/roleMgt',
                name: 'RoleMgt',
                meta: {
                  id:112,
                  parentId:11,
                  title: '角色管理',
                  icon:'el-icon-s-custom',
                  roles: ['admin'],
                  btnPermission:[
                    {
                      label:'删除',
                      value:'del',
                      id:1121,
                      checked:false
                    },{
                      label:'编辑',
                      value:'edit',
                      id:1122,
                      checked:false
                    }
                  ]
                }
              },{
                path: '/userMgt/menu',
                component: 'userMgt/menuMgt',
                name: 'MenuMgt',
                meta: {
                  id:113,
                  parentId:11,
                  title: '权限管理',
                  icon:'el-icon-menu',
                  roles: ['admin','editor']
                }
              }
            ]
          }
        ]
      }   
    ]
  },
  'editor-token': {
    roles: ['editor'],
    introduction: 'I am an editor',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'Normal Editor',
    menus:[
      {
        path: '/',
        component:'/layout',
        redirect: '/dashboard',
        children: [
          {
            path: '/dashboard',
            component: 'dashboard/index',
            name: 'Dashboard',
            meta: { title: '首页', icon: 'el-icon-s-home', affix: true,id:1,parentId:0 }
          },
          {
            path: '/userMgt',
            component: 'layout/index',
            //redirect: '/userMgt/user',
            alwaysShow: true, // will always show the root menu
            name: 'UserMgtSys',
            meta: {
              id:11,
              title: '系统管理',
              icon: 'el-icon-user-solid',
              parentId:0,
              roles: ['admin','editor']// you can set roles in root nav
            },
            children: [{
                path: '/userMgt/menu',
                component: 'userMgt/menuMgt',
                name: 'MenuMgt',
                meta: {
                  id:113,
                  parentId:11,
                  title: '权限管理',
                  icon:'el-icon-menu',
                  roles: ['admin','editor']
                }
              }
            ]
          }
        ]
      }   
    ]
  }
}

module.exports = [
  {
    url: '/vue-element-admin/user/testHttp',
    type: 'post',
    response: config => {
      
      return {
        code: 408,
        data: '408测试',
        message:'登陆超时'
      }
    }
  },
  // user login
  {
    url: '/vue-element-admin/user/login',
    type: 'post',
    response: config => {
      const { username } = config.body
      const token = tokens[username]

      // mock error
      if (!token) {
        return {
          code: 60204,
          message: 'Account and password are incorrect.'
        }
      }

      return {
        code: 20000,
        data: token
      }
    }
  },

  // get user info
  {
    url: '/vue-element-admin/user/info\.*',
    type: 'get',
    response: config => {
      const info = users['admin-token']

      // mock error
      if (!info) {
        return {
          code: 50008,
          message: 'Login failed, unable to get user details.'
        }
      }

      return {
        code: 20000,
        data: info
      }
    }
  },

  // user logout
  {
    url: '/vue-element-admin/user/logout',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }
]
